<Gui:ViewControl x:Class="Outcoder.Calcium.DiagramDesigner.DiagramDesignerView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Gui="clr-namespace:Outcoder.Calcium.Gui;assembly=Outcoder.Calcium.Client"
    xmlns:Module="clr-namespace:Outcoder.Calcium.DiagramDesigner"
	DataContext="{Binding ViewModel, RelativeSource={RelativeSource Self}}">
	<Gui:ViewControl.ViewModel>
		<Module:DiagramDesignerViewModel />
	</Gui:ViewControl.ViewModel>
	<Gui:ViewControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="DesignerDictionary.xaml"/>				
			</ResourceDictionary.MergedDictionaries>
			<Module:DesignerItemTemplateSelector x:Key="DesignerItemTemplateSelector"/>
		</ResourceDictionary>		
	</Gui:ViewControl.Resources>
	<Grid>
		<ItemsControl ItemsSource="{Binding Path=DesignerItems}">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<Canvas x:Name="Canvas_Root" 
							ClipToBounds="True" 
							SnapsToDevicePixels="True" Margin="2" Background="{DynamicResource ControlBackgroundBrush}" 
							Thumb.DragStarted="Canvas_Root_DragStarted" 
							Thumb.DragCompleted="Canvas_Root_DragCompleted" 
							PreviewMouseDown="Canvas_PreviewMouseDown" />
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
			<ItemsControl.ItemTemplate>
				<DataTemplate>
					<Module:DesignerHost>
						<ContentControl Content="{Binding}" 
										ContentTemplateSelector="{StaticResource DesignerItemTemplateSelector}" />
					</Module:DesignerHost>
				</DataTemplate>
			</ItemsControl.ItemTemplate>
			<ItemsControl.ItemContainerStyle>
				<Style>
					<Setter Property="Canvas.Top" Value="{Binding Path=Top}" />
					<Setter Property="Canvas.Left" Value="{Binding Path=Left}" />
				</Style>
			</ItemsControl.ItemContainerStyle>
		</ItemsControl>
	</Grid>
</Gui:ViewControl>